package com.gitee.mazhenggg.demo.gateway.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.CoreSubscriber;
import reactor.core.publisher.Mono;

@RestController
public class TestController {

    @Autowired
    private WebClient.Builder webclientBuilder;

    @GetMapping("/test2")
    public Mono<String> test() {
        return webclientBuilder.build()
                .get()
                .uri("http://demo-server/v1/test")
                .retrieve()
                .bodyToMono(String.class);
    }

    @GetMapping("/test")
    public Mono<String> test2() {
        return Mono.just("Hello, Reactive");
    }



}
